document.getElementById('publishForm').onsubmit = async function(e) {
    e.preventDefault();
    const title = document.getElementById('title').value;
    const price = document.getElementById('price').value;
    const description = document.getElementById('description').value;
    const image = document.getElementById('image').files[0];
    const resp = await apiPublishProduct({title, price, description}, image);
    if (resp.ok) {
        document.getElementById('msg').innerText = '发布成功！';
        document.getElementById('publishForm').reset();
    } else {
        document.getElementById('msg').innerText = '发布失败';
    }
};
